# -*- coding: utf-8 -*-
# Auther : 风雪
# Date : 2023/12/16 12:08
# File : views.py

import json
import time

from flask import Blueprint, render_template, request, jsonify, redirect, url_for, session, make_response, views
from f6zhishu.app.f6_one import F6

f6 = F6()


class F6View(views.MethodView):
    def get(self):
        vin: str = request.args.get('vin')
        cookies: str = request.args.get('cookies')
        cookies_dict: dict = json.loads(cookies)

        data = f6.mian(vin=vin, cookies=cookies_dict)
        return jsonify(data)

    def post(self):
        vin = request.args.get('vin')

        # 新增数据筛选
        module_id = request.args.get('module_id')
        key = request.args.get('key')
        data_type = request.args.get('data_type')

        cookies = request.form.get('cookie')

        print(cookies)
        print(json.loads(cookies))

        data = f6.mian(vin=vin, cookies=json.loads(cookies), module_id=module_id, key=key, data_type=data_type)
        return jsonify(data)
